<%@page import="java.util.List"%>
<%@page import="com.webshopping.entry.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	request.setAttribute("path", basePath);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>商品查询页面</title>
<script type="text/javascript">
    function deleteGoods(id){
    	var flag = confirm("确定删除么？");
    	if(flag){
    		window.open("<%=path%>/commodity/deleteCommodity.do?id="+id,"_parent");
    	}    	
    }
    
    function updateGoods(id){
    	    // alert(id);
    	     window.open("<%=path%>/commodity/getCommodity.do?commodityId="+id,"_self");
    }
    
    
    function updateImgs(id){
    	    // alert(id);
    	     window.open("<%=path%>/file/queryCommodityImg.do?commodityId="+id,"_self");
    }
</script>

</head>
<body>
	<form action="SearchGoods" method="post">

		<!-- 	<p>名称</p>
		<input type="text" id="goodsName" name="goodsName" />
		<p>类型</p>
		<select>
			<option>1</option>
			<option>2</option>
			<option>3</option>
		</select>
 -->
	</form>
	<table border="1px">
		<tr>
			<td>编号</td>
			<th>名称</th>
			<th>价格</th>
			<th>折扣</th>
			<th>品牌</th>
			<th>颜色</th>
			<th>型号</th>			
			<th>类型</th>
			<th>操作</th>
		</tr>

		<c:forEach items="${requestScope.commodities}" var="commodity">

			<tr>
				<td>${commodity.id}</td>
				<td>${commodity.name}</td>
				<td>${commodity.price}</td>
				<td>${commodity.discount}</td>
				<td>${commodity.brand}</td>
				<td>${commodity.color}</td>
				<td>${commodity.model}</td>
				<td>${commodity.goodsType.typeName}</td>

				<th><input type="button" value="删除" onclick="deleteGoods(${commodity.id})">
					<input type="button" value="修改基本信息" onclick="updateGoods(${commodity.id})">
					<input type="button" value="修改图片" onclick="updateImgs(${commodity.id})">
				</th>
			</tr>
		</c:forEach>

	</table>
</body>
</html>